<?php

namespace App\Http\Controllers\H5;
use App\Exceptions\BusinessException;
use App\Common\Constant;
use App\Common\ResponseCode;
use App\Http\Controllers\BaseController;
use App\Http\Middleware\AdminAuth;
use App\Http\Middleware\CustomerAuth;
use App\Params\H5\AfterSalesApplyParams;
use App\Services\AfterSales\AfterSalesService;
use App\Services\Base\FileService;
use App\Traits\VerifyRequestParam;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

/**
 * 售后相关控制器
 *
 * @package App\Http\Controllers\H5
 * @author WangBin
 * @date 2021-06/11
 */
class AfterSalesController extends BaseController
{
    use VerifyRequestParam;

    public function __construct()
    {
        $this->middleware(CustomerAuth::class);
    }

    /**
     * 获取售后商品信息
     *
     * @throws
     * @return
     */
    public function getGoods()
    {
        $orderId = $this->verifyInteger('order_id');
        $productId = $this->verifyInteger('product_id');
        $ret = AfterSalesService::getInstance()->getGoods($orderId, $productId);
        return $this->success($ret);
    }

    /**
     * 申请售后
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function apply()
    {
        $param = AfterSalesApplyParams::create();
        AfterSalesService::getInstance()->apply($param);
        return $this->success();
    }
}
